package com.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.entity.StatusEntity;

@Repository
public class StatusDaoImpl extends GenericDaoImpl<StatusEntity> implements StatusDao {

	public StatusEntity getStatusById(int id) {
		return getById(StatusEntity.class, id);
	}

	public List<StatusEntity> getAllStatus() {
		return getAll(StatusEntity.class);
	}

	public StatusEntity getStatusByName(String name) {
		String hql = "From StatusEntity where name= :name";
		Query query = sessionFactory.getCurrentSession().createQuery(hql);
		query.setParameter("name",name);		
		return (StatusEntity) query.uniqueResult();
	}
	
	public StatusEntity getStatusByUniqueId(String id) {
		String hql = "From StatusEntity where id= :id";
		Query query = sessionFactory.getCurrentSession().createQuery(hql);
		query.setParameter("id",id);		
		return (StatusEntity) query.uniqueResult();
	}

}
